package com.liugui.lambda;

import java.util.Arrays;
import java.util.stream.Stream;

/**
 * @ClassName: FlatMapTest
 * @Author: liugui
 * @Date: 2020-11-05 14:44
 **/
public class FlatMapTest {
    public static void main(String[] args) {
        Stream<String> stringStream1 = Stream.of("shi yan", "shi yan lou","lou yan shi");
        Stream<String> stringStream2 = Stream.of("shi yan", "shi yan lou","lou yan shi");
        Stream<String[]> mapStream = stringStream1.map(v->v.split(" "));
        Stream<String> flatMapStream = stringStream2.flatMap(v-> Arrays.stream(v.split(" ")));
        System.out.println("map:");
        mapStream.peek(System.out::println).count();
        System.out.println("flatMap:");
        flatMapStream.peek(System.out::println).count();
    }
}
